package com.beauty.inventory.repository;

import com.beauty.inventory.entity.Inventory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface InventoryRepository extends JpaRepository<Inventory, Long> {
    
    Optional<Inventory> findByProductId(String productId);
    
    List<Inventory> findByWarehouseId(String warehouseId);
    
    @Query("SELECT i FROM Inventory i WHERE i.quantity <= i.safetyStock")
    List<Inventory> findLowStockItems();
    
    @Query("SELECT i FROM Inventory i WHERE i.quantity - i.reservedQuantity > 0")
    List<Inventory> findAvailableItems();
} 